#include "KPF_Addr.h"

KPF_Addr::KPF_Addr( void )
{
	memset( &m_NetAddr, 0x00, sizeof(m_NetAddr) );
}

KPF_Addr::KPF_Addr( const char *pIP, const int16u_t iPort, const int16u_t iLocalPort )
{
	memset( &m_NetAddr, 0x00, sizeof(m_NetAddr) );
	
	if ( pIP )
	{
		int iLen = strlen(pIP);
		
		if ( iLen < sizeof( m_NetAddr.pIP ) )
		{
			memcpy( m_NetAddr.pIP, pIP, iLen + 1 );
		}	
	}
	
	m_NetAddr.iPort = iPort;
	
	m_NetAddr.iLocalPort = iLocalPort;
}

std::string KPF_Addr::getIP( void )
{
	std::string retStr( (char *) m_NetAddr.pIP );
	
	return retStr;
}
	
int16u_t KPF_Addr::getPort( void )
{
	return m_NetAddr.iPort;
}
	
int16u_t KPF_Addr::getLocalPort( void )
{
	return m_NetAddr.iLocalPort;
}

CNetAddr *KPF_Addr::getAddr( void )
{
	return &m_NetAddr;
}

void KPF_Addr::setAddr( const CNetAddr *pNetAddr )
{
	if ( pNetAddr )
	{
		m_NetAddr = *pNetAddr;	
	}
}

KPF_Addr::~KPF_Addr( void )
{
	
}
